<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>设备管理列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">

    <style>
        .table > tbody > tr > td {
            height: 30px;
            max-height: 44px;
            overflow: hidden;
        }

        .table > tbody > tr > td span {
            max-height: 44px;
            line-height: 22px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
        }

        .saveModle {
            width: 500px;
            height: 300px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -250px;
            margin-top: -150px;
            background: #fff;
            border-radius: 10px;
            z-index: 1978;
            display: none;
            border: 1px solid #cfcfcf;
        }

        .saveModle .top {
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            padding-left: 7px;
            border-bottom: 1px solid #cfcfcf;
            background: #fff;
        }

        .saveModle .top .title {
            height: 32px;
            line-height: 32px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            float: left;
            background: #fff;
        }

        .saveModle .top .btn {
            font-size: 20px;
            width: 34px;
            height: 22px;
            line-height: 12px;
            display: inline-block;
            float: right;
        }

        .saveModle .top .btn:hover {
            color: red;
        }

        .saveModle .saveBtn {
            margin: 0 auto;
            margin-top: 35px;
            display: block;

        }

        /*#tbList tr:nth-child(odd){*/
        /*background-color:#ECFAFD;*/
        /*}*/
    </style>
</head>

<body>
<section class="content" id="app">
    <div style="height: 25px;margin-bottom: 10px;">
        <div class="pull-left" style="width:120px;">
            <select id="testBran" v-model="selectBran" class="form-control" @change=""
                    style="height:25px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option value="品牌">品牌</option>
                <option v-for="itemB in itemsBran" v-bind:value="itemB.id">{{itemB.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="width:120px;margin-left:10px;">
            <select id="testType" v-model="selectType" class="form-control"
                    style="height:25px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option value="设备类型">设备类型</option>
                <option v-for="itemT in itemsType" v-bind:value="itemT.id">{{itemT.name}}</option>
            </select>
        </div>


        <button type="button" class="btn oaBtn btn-sm" @keyup.enter="search" @click="search"
                style="margin-left: 10px;">
            查询
        </button>
        <button type="button" class="btn oaBtn pull-right btn-sm"
                style="margin-right: 20px" @click="add"
        />
        品牌管理</button>
        <button type="button" class="btn oaBtn pull-right btn-sm"
                style="margin-right: 20px" @click="add"
        />
        类型管理</button>
        <button type="button" class="btn oaBtn pull-right btn-sm"
                style="margin-right: 20px" @click="add"
        />
        新增型号</button>

        <div class="clearfix"></div>
        <!-- /.box-tools -->
    </div>
    <div class="box-body no-padding iframeH2" style="overflow: auto;" id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <table class="table table-hover table-bordered text-center table-striped">
            <thead>
            <tr>

                <th style="width: 100px;">品牌</th>
                <th style="width: 80px;">设备类型</th>
                <th style="width: 60px;">型号</th>
                <th style="width: 140px;">限价(元)</th>
                <th style="width: 100px;">操作</th>
            </tr>
            </thead>
            <tbody id="tbList">
            <tr v-for="(item,i) in list">
                <td>{{item.brandName}}</td>
                <td>{{item.deviceTypeName}}</td>
                <td>{{item.modelName}}</td>
                <td>{{item.price}}</td>
                <td>
                    <a href="javascript:void(0);"
                       @click="gotoDetail(item.id,'browser',0)">&nbsp;修改&nbsp;</a>
                    <a href="javascript:void(0);"
                       @click="removeById(item.id,i)">&nbsp;删除&nbsp;</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="oa-pager text-center" style="margin-top: 5px;">
            共
            <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
            <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
            <span class="oa-pager-button" id="first">首页</span>
            <span class="oa-pager-button" id="prev">上一页</span>
            <span class="oa-pager-button" id="next">下一页</span>
            <span class="oa-pager-button" id="last">尾页</span>
        </div>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }
    var app = new Vue({
        el: '#app',
        data: {
            selectType: '设备类型',
            selectBran: '品牌',
            itemsBran: [],
            itemsType: [],
            searchParams: {
                deviceTypeName: '',
                brandName: ''
            },
            isCheckedAll: false,
            currentUser: getCurrentUser(),
            list: [],

        },
        methods: {
            getType: function () {
                var that = this;
                //var s = that.selectType;
                that.selectType = "设备类型";
                //var data = {'deviceTypeId': s.toString()};
                $.wyui.postMethod('/deviceBrand/getDeviceTypeList.json', {}, function (r) {
                    console.log(r);
                    that.itemsType = r.devicetypes;
                });
            },
            gotoDetail: function (id, pageType, isAdd) {
                $.dialog({
                    content: 'url:detail.html?type=edit&&id=' + id,
                    title: '修改设备信息',
                    width: 904,
                    height: 535,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            add: function () {
                $.dialog({
                    content: 'url:detail.html?type=add',
                    title: '添加设备',
                    width: 904,
                    height: 535,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            search: function () {
                this.searchParams.brandName = $("#testBran option:selected").text();
                this.searchParams.deviceTypeName = $("#testType option:selected").text();
                $.wyui.page.queryParams.requestPage = 1;
                $.extend($.wyui.page.queryParams, this.searchParams);
                console.log($.wyui.page.queryParams);
                $.wyui.page.getByPage();
            },
            removeById: function (id, i) {
                if (confirm('确认要删除吗？')) {
                    var that = this;
                    $.wyui.postMethod("/deviceModel/delById.json", {id: id}, function (result) {
                        location.reload();
                    });
                }
            },
        },
        mounted: function () {
            var that = this;
            $.wyui.postMethod('/deviceBrand/getBrandList2.json', {}, function (r) {
                console.log(r);
                that.itemsBran = r.brands;
            })
            /*获取类型*/
            that.selectType="设备类型";
            $.wyui.postMethod('/deviceBrand/getDeviceTypeList.json', {}, function (r) {
                console.log(r);
                that.itemsType = r.devicetypes;
            });
            //获取临时事项类型
        }
    });

    $.wyui.page.dataUrl = server.ip + "/device/getDevicePage.json"
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams, app.searchParams);
    $.wyui.page.getByPage_callback = function (records) {
        app.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        }
    };
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
</body>
</html>